package com.acme.domain.account;

import com.acme.exceptions.NotEnoughFundsException;
import com.acme.exceptions.OverDraftLimitExceedException;


public class CheckingAccount extends AbstractAccount{
	private double overdraft;
	
	public CheckingAccount(final double amount, final double overdraft) {
		super(amount);
		if (overdraft<0){
			throw new IllegalArgumentException("overdraft");
		}
		this.overdraft = overdraft;

	}
	public void withdraw(double amount) throws NotEnoughFundsException{
		if  (this.balance < amount - this.overdraft) {
			throw new OverDraftLimitExceedException();
		}
		this.balance -= amount;
	}
	
	public double maximumAmountToWithdraw(){
		return (this.balance + this.overdraft);
	}
	
	public String toString() {
		return "[ id:" + id + "; balance:" + this.balance + "; overdraft:" + this.overdraft +" ]"; 
	}
	
	public String shortAccType() {
		return "c";
	}
	
	public double getOverdraft() {
		return this.overdraft;
	}
	
}